﻿using DependencyAnalysis.DataModel;
using DependencyAnalysis.Internal;
using DependencyAnalysis.Serialization;
using NUnit.Framework;

namespace NUnitExample
{
    [TestFixture]
    public class DependencyAnalysisAccessTest : DependencyTest
    {
        [Test]
        public void CilParserIsAccessedByAnalyzerOnly()
        {
            var analyzer = DescriptorBuilder.BuildTypeDescriptor(typeof(Analyzer));
            var cilParser = DescriptorBuilder.BuildTypeDescriptor(typeof(CilParser));
            Verifier.VerifyNoOtherReferrers(new[] { analyzer }, cilParser);
        }

        [Test]
        public void ReportsAreAccessedByInterface()
        {
            var dependencyAnalysis = DescriptorBuilder.BuildModuleDescriptor(typeof(DependencyAnalysis.Properties.IAssemblyIdentifier).Assembly);
            var metricsReport = DescriptorBuilder.BuildTypeDescriptor(typeof(MetricsReport));
            var codesmellReport = DescriptorBuilder.BuildTypeDescriptor(typeof(CodeSmellReport));
            var duplicationReport = DescriptorBuilder.BuildTypeDescriptor(typeof(DuplicationReport));

            Verifier.VerifyAccessType(dependencyAnalysis, metricsReport, AbstractionType.Interface);
            Verifier.VerifyAccessType(dependencyAnalysis, codesmellReport, AbstractionType.Interface);
            Verifier.VerifyAccessType(dependencyAnalysis, duplicationReport, AbstractionType.Interface);
        }
    }
}
